package demo1;

public class BinarySearchTree {
static class TreeNode {
public int val;
public TreeNode left;
public TreeNode right;
public TreeNode(int val) {
this.val = val;
}
}

public TreeNode root = null;
/**
* 查找二叉搜索树中指定的val值
* @param val
* @return
*/
public TreeNode find(int val) {
    TreeNode cur = root;
    while (cur != null) {
        if (cur.val == val) {
            return cur;
        }
        if (cur.val < val) {
            cur = cur.right;
        } else {
            cur = cur.left;
        }
    }
    return null;
}

}